package br.trainee.web.constraint.impl;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import br.trainee.web.constraint.service.Cpf;

public class CpfImpl implements ConstraintValidator<Cpf, String>{
	
	private String mensagem;
	
	@Override
	public void initialize(Cpf anotacao) {
		
		this.mensagem = anotacao.message();
		
	}

	@Override
	public boolean isValid(String valor, ConstraintValidatorContext context) {
		
			if(!valor.matches("[0-9]{3}\\.?[0-9]{3}\\.?[0-9]{3}\\-?[0-9]{2}")){
				return false;
			}
			
		
		
		return true;
	}

}
